package com.tony.concurrent.BlockQueneTest;

import java.util.concurrent.BlockingQueue;

public class Producer implements Runnable {
    private BlockingQueue blockingQueue;

    public Producer(BlockingQueue blockingQueue){
        this.blockingQueue = blockingQueue;
    }

    @Override
    public void run() {
        try {
            for(int i=0;i<10;i++) {
                blockingQueue.put(i);
                System.out.println("producer put:"+i);
                Thread.sleep(100);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
